function converToPinyin(text, type = 1) {
    const typeMap = { 1: 'symbol', 2: 'num', 3: 'none' };
    const toneType = typeMap[Number(type)] || 'symbol';
    return pinyinPro.pinyin(text, { toneType });
}

const converColor = {
    hexToRgb(hex) {
        hex = hex.replace(/^#/, '');
        if (!/^([0-9A-F]{3}){1,2}$/i.test(hex)) return null;

        let r, g, b;
        if (hex.length === 3) {
            r = parseInt(hex[0] + hex[0], 16);
            g = parseInt(hex[1] + hex[1], 16);
            b = parseInt(hex[2] + hex[2], 16);
        } else {
            r = parseInt(hex.substr(0, 2), 16);
            g = parseInt(hex.substr(2, 2), 16);
            b = parseInt(hex.substr(4, 2), 16);
        }
        return { r, g, b };
    },

    rgbToCmyk(r, g, b) {
        if (r === 0 && g === 0 && b === 0) {
            return { c: 0, m: 0, y: 0, k: 100 };
        }

        let c = 1 - r / 255;
        let m = 1 - g / 255;
        let y = 1 - b / 255;
        const k = Math.min(c, m, y);

        c = (c - k) / (1 - k);
        m = (m - k) / (1 - k);
        y = (y - k) / (1 - k);

        return {
            c: Math.round(c * 100),
            m: Math.round(m * 100),
            y: Math.round(y * 100),
            k: Math.round(k * 100)
        };
    },

    cmykToRgb(c, m, y, k) {
        const r = 255 * (1 - c / 100) * (1 - k / 100);
        const g = 255 * (1 - m / 100) * (1 - k / 100);
        const b = 255 * (1 - y / 100) * (1 - k / 100);

        return {
            r: Math.round(r),
            g: Math.round(g),
            b: Math.round(b)
        };
    },

    rgbToHex(r, g, b) {
        return '#' + [r, g, b]
            .map(x => x.toString(16).padStart(2, '0'))
            .join('')
            .toUpperCase();
    }
};